/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dialogEditor.elements;


import dialogEditor.diaStructEdit;
import java.awt.Color;
import java.awt.List;
import java.util.ArrayList;
import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType;
import org.netbeans.api.visual.border.BorderFactory;
import org.netbeans.api.visual.layout.LayoutFactory;
import org.netbeans.api.visual.widget.LabelWidget;
import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Scene;
import org.netbeans.api.visual.widget.Widget;


/**
 *
 * @author sl_ru
 */
public class DialogPhraseWidget extends diaStructWidgetAbstact
{  
    diaStructEdit sc;
    
    String mainColor = "#808080", nameColor = "#FDFDFD", defColor = "#A4A4A4", borderColor = "#D2D2D2";
    
    public DialogPhraseWidget(diaStructEdit scene, String ID)
    {
        super(scene, ID);
        
        sc = scene;
        

        setBorder(BorderFactory.createRoundedBorder(9, 9, Color.decode(mainColor), Color.decode(borderColor)));
        setLayout(LayoutFactory.createVerticalFlowLayout());
        
        getActions().addAction(sc.resizeAction);
        getActions().addAction(sc.moveAction);
        getActions().addAction(sc.createWidgetHoverAction());
        getActions().addAction(sc.connectAction);

        canBeTarget = true;
        canBeSource = false;
        
        setLable(ID);
        addPin();
    }
    
    void setLable(String text)
    {
        LabelWidget l = new LabelWidget(sc, text);
        addChild(l);
    }
    
    
    public ArrayList<diaStructWidgetAbstact> pins = new ArrayList<diaStructWidgetAbstact>();
    void addPin()
    {
        diaStructWidgetAbstact pin = new diaStructWidgetAbstact(sc, id + String.valueOf(pins.size()));
        pin.addChild(new LabelWidget(sc, pin.id));
        pin.getActions().addAction(sc.createWidgetHoverAction());
        pin.getActions().addAction(sc.connectAction);
        pin.canBeSource = true;
        pin.canBeTarget = false;
        pin.setBorder(BorderFactory.createRoundedBorder(10, 10, Color.decode(nameColor), Color.decode(borderColor)));
        pin.parent = id;
        addChild(pin);
        pins.add(pin);
    }
    
}
